package br.com.ucb.projFinal.forms.cadastro;
import br.com.ucb.projFinal.beans.AgregarProducto;
import br.com.ucb.projFinal.beans.ManipulaEntradaDados;
import br.com.ucb.projFinal.beans.TProducto;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;


@SuppressWarnings("serial")
public class FormAgregarProducto extends FormAgregoProducto{

	private JLabel jlcantidadStock;

	

	static Integer[] cantidadStock = { 1,2,3,4,5,6,7,8,9,10,
										11,12,13,14,15,16,17,18,19,20,
										21,22,23,24,25,26,27,28,29,30,
										31,32,33,34,35,36,37,38,39,40,
										41,42,43,45,45,46,47,48,49,50};
	
	static String[] Nombre = { "Papel Higienico","Alfajor","Aceite","Crema Doble","Leche","Pan","Papas Lays","Papas Pringles",
		"Fanta 1.25L","Fanta 2.00L ","Coca Cola 1.25L","Coca Cola 2.25L","Galletas Bridge","Galletas Surtidas","Detergente","Helado Conaprole",
		"Helado Crufi","Cerveza Pilsen","Cerveza Patricia","Cerveza Zillertal","Cerveza Corona","Cerveza Heineken","Cerveza Brahma",
		"Vodka 1L","Whisky Jhonny 5L","Cerveza 5L","Mayonesa Hellmans","Hamburguesas Hamby","Hamburguesas Patty","Dulce de Leche Conaprole",
		"Caffe Importado","Yogurth Conaprole","Sandwiches Surtidos","Pack para Copetin","Cepillo de Dientes","Televisor 54'' ","Cigarros Marlboro",
		"Petaca Grapamiel","Grapamiel Vesubio 1L","Grapamiel Victoria","Tequila el Charro Viejo","Vodka Absolut","Nuggets de pollo 1k",
		"Hamburguesas de merluza empanadas","Papas noissete 1k","Mejillones Congelados 1k","Camarones Congelados 500g","Calamares Congelados 1k",
        };
	
	
	public TProducto recibeDatos(){
		
    TProducto producto = new TProducto();
	
	if ((ManipulaEntradaDados.ValidaString(getJtfNombre().getText()))==null)
		return null;
	
	if ((ManipulaEntradaDados.ValidaCodigoBarra(getJtfCodigoBarra().getText())) != null)
		return null;
	
	if ((ManipulaEntradaDados.ValidaCantidadStock(getJlcantidadStock())) != null)
		return null;
	

	
	
	producto.setNombre(getJtfNombre().getText());
	producto.setEtiqueta(setJlCodigoBarra(Integer.parseInt(getJtfCodigoBarra().getText())));
	producto.setStock(Integer.parseInt(getJlcantidadStock().getText())); // aca esta para pasarlo a int

	return producto;
	
}

public FormAgregarProducto() {
	setLayout(new FlowLayout(20,20,20));
	setPreferredSize(new Dimension (700,500));
	
	initObjectsUI();
	
	add(getJtfNombre());
	//add(getJlCodigoBarra());
	add(getJlcantidadStock());

	
	add(getJbOk());
	setLayout(new FlowLayout(40,50,30));
	setBorder(BorderFactory.createLineBorder(Color.blue));
}

public void initObjectsUI() {
	setJtfNombre(new JTextField());
	getJtfNombre().setPreferredSize( new Dimension(500, 20) );
	setJlNombre(new JLabel("Nombre: "));
	
	//setJtfCodigoBarra(new JTextField());
	//getJlCodigoBarra().setPreferredSize( new Dimension(150, 20) );
	//setJlCodigoBarra(new JLabel("Codigo de Barra: "));
		
	setJtfCantidadStock(new JComboBox(cantidadStock));
	getJlcantidadStock().setPreferredSize( new Dimension(60, 20) );
	setJlCantidadStock(new JLabel("cantidadStock: "));
	
	
	
	setJbOk(new JButton(" Agregar "));
	getJbOk().addActionListener(new AgregarProducto(this));

}

public JLabel getJlcantidadStock() {
	return jlcantidadStock;
}

public void setJlcantidadStock(JLabel jlcantidadStock) {
	this.jlcantidadStock = jlcantidadStock;
}



	
}